#include "main.h"
__HufTree * mkH_TInit (FILE * fileToRead)
{

	int i = 0;
	int rc = 0;
	int count = 1;
	int firstElement = 0;
	__HufTree ** H_T = (__HufTree**) calloc (256, sizeof(__HufTree*));
	__HufTree * head = NULL;
	unsigned char buf[] = "";
	fseek (fileToRead,0,SEEK_SET);
	H_T = (__HufTree **) calloc (256,sizeof(__HufTree*));
	envInf.HufTree_list = H_T;
	if (!H_T)	cl_exit (HUF_TREE_INIT,MEMORY_ERR);
	while ((rc = fread (buf,sizeof(char),SIZE_T_1,fileToRead)) == 1)
	{
		if (!H_T[buf[0]])	H_T[buf[0]] = (__HufTree *) calloc (1,sizeof(__HufTree));
		if (!H_T[buf[0]])	cl_exit (HUF_TREE_INIT,MEMORY_ERR);
		if (H_T [buf[0]]->count == 0)	H_T [buf[0]]->alpha = buf[0];
		H_T [buf[0]]->count++;
	}
	H_T = SortHuffTree (H_T);
	envInf.HufTree_list = H_T;
	H_T[3];
	head = MakeHufTree (H_T);
	envInf.HufTree = head;
	envInf.HufTree_list = NULL;
	return head;
}